<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title>地址列表</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/address.css">
    <include file="Public/common_js"/>
</head>
<body>
<div class="warp">
    <div class="address-list">
        <ul>
         <volist name="addList" id="addr">
            <li class="isSelect" data-id="{$addr.addr_id}">
                <p class="clearfix"><span class="fl">{$addr.name}</span><span class="fr">{$addr.mobile}</span></p>
                <p class="text-hide"><if condition="$addr.def_addr  eq 1 "><label>默认地址</label></if>{$addr.area}{$addr.addr}</p>
            </li>
        </volist>
        </ul>
    </div>
</div>
<div id = 'dataUrl' data-url="{:url('home/address/changeAddress')}"></div>
<div class="address-new"><a href="{:U('address/addressModify')}" class="btn btn-block ">+新建地址</a></div>
<script type="text/javascript">
	require(['address']);
</script>
</body>
</html>

<script>
    $('.isSelect').on('click',function(){
        $.ajax({
            url:"{:url(Address/changeAddress)}",
            type:'post',
            data:{'addr':$(this).data('id')},
            datatype:'json',
            success:function (data) {
                if(data.status==1){
                    window.location.href=data.url;
                } else{
                    alert('地址选择失败');
                }
            },
            error:function (err) {
                alert('地址选择失败');
            }
        })
    })

</script>